package com.wn.date20190814;

import java.util.Random;

public class User
{
	private String name;
	private int no;
	private int age;
	public User(String name)
	{
		this.age=(int)(Math.random()*100);
		this.name=name;
		this.no=this.hashCode()%10;
	}
	public String getName()
	{
		return name;
	}
	public void setName(String name)
	{
		this.name = name;
	}
	public int getNo()
	{
		return no;
	}
	public void setNo(int no)
	{
		this.no = no;
	}
	public int getAge()
	{
		return age;
	}
	public void setAge(int age)
	{
		this.age = age;
	}
	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + age;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + no;
		return result;
	}
	@Override
	public boolean equals(Object obj)
	{
		if (this == obj)
			return true;
		if(obj instanceof User)
		{
			User u=(User)obj;
			if(u.getName().equals(name)&&u.getNo()==no)
			{
				return true;
			}
		}
		return false;
	}
	@Override
	public String toString()
	{
		return "User [name=" + name + ", no=" + no + ", age=" + age + "]";
	}
}
